<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>{$is_language?'抵押記錄':'Mortgage records'}</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/weui.min.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/jquery-weui.css">
    <link rel="stylesheet" href="__MODULE_LIBS__/css/demos.css">
    <script src="__MODULE_LIBS__/js/jquery-2.1.4.js"></script>
    <script src="__MODULE_LIBS__/js/fastclick.js"></script>
    <script src="__MODULE_LIBS__/js/jquery-weui.js"></script>
    <style type="text/css">
        * {
            margin: 0;
            padding: 0;
        }

        html {
            width: 100%;
            height: 100%;
            font-size: 20px;
            font-family: "Microsoft YaHei", "宋体", "Segoe UI", "Lucida Grande", Helvetica, Arial, sans-serif, FreeSans, Arimo;
            background: #F3F3F3;
        }

        body {
            margin: 0 auto;
            max-width: 750px;
            height: 100%;
            background: #F7F7F7;
        }

        /*顶部导航栏处的样式*/
        .navbar {
            position: relative;
            width: 100%;
            height: 2rem;
            font-size: 16px;
            color: #fff;
            line-height: 2rem;
            background: #373553;
        }

        .navbar-item {
            position: absolute;
            left: 0;
            top: 0;
            display: block;
            width: 3.2rem;
            height: 2rem;
            font-size: 14px;
            color: #fff;
            text-align: center;
        }

        .navbar-item > img {
            width: 0.8rem;
            height: 0.7rem;
            vertical-align: middle;
        }

        .navbar-center {
            text-align: center;
        }

        /*主体部分的样式*/
        .content {
            width: 100%;
        }

        /*搜索框样式*/
        .weui-grids:before, .weui-grids:after, .weui-grid:before {
            border: 0;
        }

        .weui-grid {
            padding: 0.5rem 0.4rem;
            background: #EFEFF4;
        }

        .weui-grid > input, .weui-grid > select {
            width: 100%;
            height: 1.5rem;
            color: #777;
            border: 1px #d9d9d9 solid;
            outline: none;
            border-radius: 0.3rem;
        }

        .weui-grid > input[type="text"] {
            padding-left: 0.2rem;
            height: 1.4rem;
        }

        .weui-grid > input[type="submit"] {
            font-size: 0.8rem;
            color: #F44444;
            line-height: 1.4rem;
            background: none;
            border: 0;
        }

        .weui-grid option {
            width: inherit;
            text-align: center;
        }

        .weui-grid {
            width: 80%;
        }

        .search {
            width: 20%;
        }

        /*列表处的样式*/
        .weui-cells {
            margin-top: 0.7rem;
            font-size: 0.7rem;
        }

        .weui-cell {
            padding: 0.4rem 0.5rem;
        }

        .weui-cell__hd {
            width: 6.0rem;
        }

        .status {
            margin-top: 0.2rem;
            font-size: 0.65rem;
        }

        .red {
            color: #F44444;
        }

        .blue {
            color: #468EE6;
        }

        .grey {
            color: #888;
        }

        .money {
            font-size: 0.65rem;
            color: #F44444;
        }

        .weui-cell__ft {
            padding-left: 0.2rem;
            font-size: 0.6rem;
        }

        .pagination > li {
            float: left;
            padding: 2px 6px;
            margin: 0 4px;
            list-style: none;
            color: #fff;
            background: #aaa;
            border-radius: 5px;
        }

        .pagination > li > a {
            color: #fff;
        }

        .pagination > li.active {
            background: #f44444;
        }
        .diya {
            border: 1px solid red;
            border-radius: 10%;
            padding: 2px 5px;
            color: #fff;
            background-color: red;
        }
        .weui-cell6 {
            padding: 0.4rem 0.5rem;
            font-size: 12px;
            color: red;
        }
    </style>
</head>
<body>
<header class="navbar">
    {if isset($user)}
    <a href="{:url('main')}" class="navbar-item">
        {else}
        <a href="{:url('main')}" class="navbar-item">
            {/if}
            <img src="__MODULE_LIBS__/img/back.png"/>&nbsp;{$is_language?'返回':'Return'}
        </a>
        <div class="navbar-center">{$is_language?'抵押記錄':'Mortgage records'}</div>
        <div class="navbar-item1">
            <select name="" id="yy">
                <option value="1" {$is_language?'selected':''}>中文</option>
                <option value="0" {$is_language?'':'selected'}>English</option>
            </select>
        </div>
</header>
<div class="content">
    <!--重复部分开始-->
    {volist name='list' id="v" }
    <div class="weui-cells">
        <div class="weui-cell" style="display: flex;justify-content: space-between;font-size: 12px;color: #999;">
            <p>{$is_language?'時間':'Time'}：{$v.create_time|date="Y-m-d H:i:s",###}</p>
            <p>{$is_language?'抵押天數':'Mortgage days'}：{$v.day}</p>
            <p>{$is_language?'已过天數':'Mortgage days'}：{$v.past_time}</p>
        </div>
        <div class="weui-cell">
            <div class="weui-cell__hd">
                <p>{$is_language?'抵押人':'Mortgagor'}：{$v.nickname}</p>
                <p>{$is_language?'日利率':'interest rate'}：{$v.mortgage*100}%</p>
            </div>
            <div class="weui-cell__bd">
                <p class="time">{$is_language?'資產价值':'Mortgage assets'}：{$v.goods_money*$v.sum}</p>
                <p class="time">{$is_language?'實際借款':'Capital'}：{$v.money}</p>
                <p class="time">{$is_language?'此單收益':'profit'}：{$v.redeem_money}</p>
            </div>
            <div class="weui-cell__ft">
                {if ($v.status==0)}
                <p class="status">{$is_language?'審核中':'under review'}</p>
                {elseif ($v.status==1)}
                <p class="status">{$is_language?'抵押中':'Being mortgaged'}</p>
                {elseif ($v.status==2)}
                <p class="status">{$is_language?'已贖回':'Redeemed'}</p>
                {elseif ($v.status==3)}
                <p class="status">{$is_language?'已典當':'Already pawn'}</p>
                {elseif ($v.status==4)}
                <p class="status">{$is_language?'已取消':'User canceled'}</p>
                {elseif ($v.status==5)}
                <p class="status">{$is_language?'審核拒絕':'Audit rejected'}</p>
                {/if}

                {if ($v.status==0)}
                <span class="diya agree">{$is_language?'同意':'agree'}</span>
                <span class="diya refuse">{$is_language?'拒絕':'refuse'}</span>
                {/if}
                <input name="id" type="hidden" value="{$v.id}"/>
                {if ($v.status==1)}
                <p class="diya yuqi">{$is_language?'逾期典當':'Overdue pawn'}</p>
                {/if}
            </div>
        </div>
        {if ($v.status==6)}
        <div class="weui-cells" style="margin-top: 0">
            <div class="weui-cell6">{$is_language?'有人向您申请抵押借贷，由于您的余额不足，该笔交易被取消，请及时补充您的余额':'Someone applies to you for a mortgage loan. Because of your insufficient balance, the transaction is canceled. Please replenish your balance promptly'}</div>
        </div>
        {/if}
    </div>
    {/volist}
    <!--重复部分结束-->
</div>

<script type="text/javascript">
    $(document).on("click",'span.agree',function(){
        var id = $(this).next().next('input').val();
        var url = "{:url('mortgage/record')}";
        $.confirm({
            title: '提示(prompt)',
            text: '确认此操作？（Confirm this operation?）',
            onOK: function () {
                $.post(url,{id:id,status:1},function (data) {
                    $.alert({
                        title: '提示(prompt)',
                        text: data.msg,
                        onOK: function () {
                            window.location.reload();
                        }
                    })
                })
            }
        })
    });
    $(document).on("click",'span.refuse',function(){
        var id = $(this).next('input').val();
        var url = "{:url('mortgage/record')}";
        $.confirm({
            title: '提示(prompt)',
            text: '确认此操作？（Confirm this operation?）',
            onOK: function () {
                $.post(url,{id:id,status:5},function (data) {
                    $.alert({
                        title: '提示(prompt)',
                        text: data.msg,
                        onOK: function () {
                            window.location.reload();
                        }
                    })
                })
            }
        })
    });
    $(document).on("click",'p.yuqi',function(){
        var id = $(this).prev('input').val();
        var url = "{:url('mortgage/record')}";
        $.confirm({
            title: '提示(prompt)',
            text: '确认此操作？（Confirm this operation?）',
            onOK: function () {
                $.post(url, {id: id, status: 3}, function (data) {
                    $.alert({
                        title: '提示(prompt)',
                        text: data.msg,
                        onOK: function () {
                            window.location.reload();
                        }
                    })
                })
            }
        })
    });

    $(document).on("change",'select#yy',function(){
        var yy = $(this).val();
        console.log(yy)
        var url = "{:url('index/language')}";
        $.post(url,{language:yy},function (res) {
            window.location.reload();
        })
    });
    $(function () {
        FastClick.attach(document.body);
    })
</script>
</body>
</html>
